package com.eric.domain.po;

import com.mybatisflex.annotation.*;
import lombok.Data;

import java.util.Date;
import java.util.List;

@Table("tb_role")
@Data
public class Role {

    @Id(keyType = KeyType.Auto)
    private Integer id;
    private String name;
    private Integer version;

    @Column(isLogicDelete = true,onInsertValue = "0")
    private Integer isDeleted;

    @Column(value = "create_time", onInsertValue = "now()")
    private Date createTime;

    @Column(value = "update_time",onInsertValue = "now()", onUpdateValue = "now()")
    private Date updateTime;

//    Role和Account的关系是多对多关系
    @RelationManyToMany(
            joinTable = "tb_role_mapping",//中间表
//           selfField 当前实体类的属性，joinSelfColumn 当前表和中间表的关系字段
//            搞清楚，属性指的是类对象中的属性，字段是数据库表中的字段，不一样的
            selfField = "id",joinSelfColumn = "role_id",
//            targetField 目标对象的关系实体类的属性，joinTargetColumn 目标表和中间表的关系字段
//            搞清楚，属性指的是类对象中的属性，字段是数据库表中的字段，不一样的
            targetField = "id",joinTargetColumn = "account_id"
    )
    private List<Account> accountList;



}
